<template>
    <div class="block">
        <el-row type="flex">
            <el-col :span="1">
                <el-button type="text" icon="el-icon-back" round @click="prev">返回</el-button>
            </el-col>
        </el-row>
        <el-row type="flex" class="row-bg1" justify="center">
            <el-col :span="6">
                <h3> {{ }}</h3>
            </el-col>
        </el-row>
               
        <div class="table_block">
            <el-table
                :data="tableData"
                stripe
                style="width: 100%"
                class="tableDatadisplay">
                <el-table-column
                    label="账户名称"
                    align="center">
                    <template slot-scope="scope">
                        <div>{{scope.row.accountName}}</div>
                    </template>
                </el-table-column>                                 
                <el-table-column
                    label="交易时间"
                    align="center">
                    <template slot-scope="scope">
                        <span>{{$moment(scope.row.createTime).format('YYYY-MM-DD HH:mm:ss')}}</span>
                    </template>
                </el-table-column>
                <el-table-column
                    label="原账户余额"
                    align="center">
                    <template slot-scope="scope">
                        <span>{{scope.row.accountBalance}}</span>
                    </template>
                </el-table-column> 
                <el-table-column
                    label="交易金额"
                    align="center">
                    <template slot-scope="scope">
                        <span>{{scope.row.dealBalance}}</span>
                    </template>
                </el-table-column>
                <el-table-column
                    label="交易后账户余额"
                    align="center">
                    <template slot-scope="scope">
                        <span>{{scope.row.dealAccountBalance}}</span>
                    </template>
                </el-table-column>                                                               
                <el-table-column
                    label="账户类型"
                    align="center">
                    <template slot-scope="scope">
                        <div v-if="scope.row.dealType == 1" style="color:green;">{{scope.row.dealType | dataFormat(dealTypeArray)}}</div>
                        <div v-else style="color:red;">{{scope.row.dealType | dataFormat(dealTypeArray)}}</div>
                    </template>                    
                </el-table-column>               
            </el-table>
        </div>



        <div style="margin-top: 50px" >
        <!--prev表示上一页，next为下一页，pager表示页码列表,total表示总条目数，size用于设置每页显示的页码数量。-->
            <el-pagination
                background
                layout="total,prev,sizes, pager, next,jumper"
                :total="total"
                :page-sizes="[5, 10, 15, 20]"
                :page-size.sync="formSearch.pageSize"
                :current-page.sync="formSearch.pageNum"
                @current-change="getPage"
                @size-change="getPage"
                style="float: center">
            </el-pagination>
        </div>        
    </div>
</template>

<script>
import bus from '../../../api/eventBus';
import log from '../../../api/log';
import deal from '../../../api/deal';

export default {
    name:"noticeDetails",
    data(){
        return{
            tableData:[],
            total:0,
            formSearch:{
                pageNum:1,
                pageSize:10
            },
            dealTypeArray:[
                {value:1,name:'成功'},
                {value:0,name:'失败'}                                                                
            ],            
        }
    },
    created(){
        this.page()
    },
    filters:{
        //类型过滤
        dataFormat(value,list){
            return value || value == '1' ? list.filter( (item) => item.value == value)[0].name:""
        }
    },    
    mounted(){

    },
    methods:{
        page(){
            bus.$on("accountId", res => {
                this.formSearch.accountId = res
                this.getPage()
            })

        },
        async getPage(res){
            const ress = await deal.list(this.formSearch)
            if( ress.data.code === '000'){
                this.tableData=ress.data.data.records;
                this.total=ress.data.data.total;
            }
        },
        prev(){
            this.$router.go(-1)
        }

    }
}
</script>

<style lang="scss" scoped >

</style>
